/**
 * @details: 
 * @brief: 
 * @version: 1.0
 * @author: liuri
 * @Date: 2021-10-05 05:40:52
 * @LastEditors: liuri
 * @LastEditTime: 2021-10-07 01:35:19
 * @FilePath: /TestProject/cPath/vtysh/cmd_matcher.h
 * @Copyright (C) 2021 liuri. All rights reserved.
 */
#ifndef __CMD_MATCHER_H__
#define __CMD_MATCHER_H__

enum matcher_rv
{
    MATCHER_OK,               // 当前节点匹配成功
    MATCHER_COMPLETE,         // 匹配完成，
    MATCHER_INCOMPLETE,
    MATCHER_NO_MATCH,
    MATCHER_AMBIGUOUS,
    MATCHER_EXCEED_ARGC_MAX
};

#define MATCHER_ERROR(matcher_rv) \
  (   (matcher_rv) == MATCHER_INCOMPLETE \
   || (matcher_rv) == MATCHER_NO_MATCH \
   || (matcher_rv) == MATCHER_AMBIGUOUS \
   || (matcher_rv) == MATCHER_EXCEED_ARGC_MAX \
  )
  
// 匹配器
struct cmd_matcher
{
    // struct cmd_element *cmd; /* The command element the matcher is using */
    // enum filter_type filter; /* Whether to use strict or relaxed matching */
    enum match_type match_type; // 匹配类型，也是优先级
    uint32_t index;         /**< 上一轮中匹配的最大深度 */
    vector match;           /**< 存储匹配的 cmd_token 字段 */
    vector vline;           /**< 输入命令 vline 关键字向量 */   
    uint32_t word_index;    /**< 输入命令 vline 的下标 */
};


void cmd_matches_free(vector *matches);

int cmd_vector_filter(struct cmd_matcher *,  vector commands, vector vline, uint32_t index);

#endif

